#include "stdafx.h"
#include "LogTargetFile.h"
#include <fstream>

namespace woe
{
	LogTargetFile::LogTargetFile(const string& file)
		:log_file_name_(file)
	{

	}

	LogTargetFile::~LogTargetFile()
	{

	}

	bool LogTargetFile::initialize()
	{
		log_file_stream_.open(log_file_name_.c_str(), std::ios_base::out | std::ios_base::trunc);
		if (log_file_stream_.good())
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	void LogTargetFile::doLog(const string& msg, const string& ll,  const TimeStamp& ts)
	{
		if (log_file_stream_.good())
		{
			log_file_stream_<<ts.getSeconds()<<ts.getMilliSeconds()<<" -"<<ll <<"> "<<msg;
		}
	}
}